package com.luisliuyi.demo.webrtc;

import android.app.Activity;
import android.text.TextUtils;

import com.luisliuyi.demo.webrtc.bean.MediaType;
import com.luisliuyi.demo.webrtc.bean.MyIceServer;
import com.luisliuyi.demo.webrtc.ui.ChatRoomActivity;
import com.luisliuyi.demo.webrtc.ui.ChatSingleActivity;
import com.luisliuyi.demo.webrtc.ws.IConnectEvent;

public class WebrtcUtil {

    private final static String TAG = "WebrtcUtil";

    //本地测试信令地址
    private static String WSS = "wss://124.221.122.152/wss";

    private static MyIceServer[] iceServers = {
            new MyIceServer("stun:124.221.122.152:3478?transport=udp"),
            new MyIceServer("turn:124.221.122.152:3478?transport=udp",
                    "liuyi",
                    "123456"),
    };

    public static void call(final Activity activity, String wss, String roomId) {
        if (TextUtils.isEmpty(wss)) {
            wss = WSS;
        }
        WebRTCManager.getInstance().init(wss, iceServers, new IConnectEvent() {
            @Override
            public void onSuccess() {
                ChatRoomActivity.openActivity(activity);
            }

            @Override
            public void onFailed(String msg) {

            }
        });
        WebRTCManager.getInstance().connect(MediaType.TYPE_MEETING, roomId);
    }
}
